//
//  ShareUtil.m
//  GuiJuWo
//
//  Created by chenguibang on 16/3/29.
//  Copyright © 2016年 chenguibang. All rights reserved.
//

#import "ShareUtil.h"

@implementation ShareUtil
- (instancetype)init
{
    self = [super init];
    if (self) {
        [ShareSDK registerApp:@"1101af10b051e"
         
              activePlatforms:@[
                                @(SSDKPlatformTypeSinaWeibo),
                                @(SSDKPlatformTypeMail),
                                @(SSDKPlatformTypeSMS),
                                @(SSDKPlatformTypeWechat),
                                @(SSDKPlatformTypeQQ),
                                ]
                     onImport:^(SSDKPlatformType platformType)
         {
             switch (platformType)
             {
                 case SSDKPlatformTypeWechat:
                     [ShareSDKConnector connectWeChat:[WXApi class]];
                     break;
                 case SSDKPlatformTypeQQ:
                     [ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]];
                     break;
                 case SSDKPlatformTypeSinaWeibo:
                     [ShareSDKConnector connectWeibo:[WeiboSDK class]];
                     break;
                 default:
                     break;
             }
         }
              onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)
         {
             
             switch (platformType)
             {
                 case SSDKPlatformTypeSinaWeibo:
                     //设置新浪微博应用信息,其中authType设置为使用SSO＋Web形式授权
                     [appInfo SSDKSetupSinaWeiboByAppKey:@"568898243"
                                               appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
                                             redirectUri:@"http://www.sharesdk.cn"
                                                authType:SSDKAuthTypeBoth];
                     break;
                 case SSDKPlatformTypeWechat:
                     [appInfo SSDKSetupWeChatByAppId:@"wx4868b35061f87885"
                                           appSecret:@"64020361b8ec4c99936c0e3999a9f249"];
                     break;
                 case SSDKPlatformTypeQQ:
                     [appInfo SSDKSetupQQByAppId:@"100371282"
                                          appKey:@"aed9b0303e3ed1e27bae87c33761161d"
                                        authType:SSDKAuthTypeBoth];
                     break;
                 case SSDKPlatformTypeRenren:
                     [appInfo        SSDKSetupRenRenByAppId:@"226427"
                                                     appKey:@"fc5b8aed373c4c27a05b712acba0f8c3"
                                                  secretKey:@"f29df781abdd4f49beca5a2194676ca4"
                                                   authType:SSDKAuthTypeBoth];
                     break;
                 default:
                     break;
             }
         }];

    }
    return self;
}

+(ShareUtil *)initShareUtil{
    static dispatch_once_t onceToken;
    static ShareUtil *shareUtil;
    dispatch_once(&onceToken, ^{
        shareUtil = [[self alloc]init];
    });
    return shareUtil;
}
@end
